package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordMaintenanceDto;
import com.yqg.protection.entity.RecordMaintenance;
import com.yqg.protection.mapper.RecordMaintenanceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 14:34
 * description:
 */
@Component
public class RecordMaintenanceListener extends AnalysisEventListener<ImportRecordMaintenanceDto> {

    @Autowired
    private RecordMaintenanceMapper recordMaintenanceMapper;

    @Override
    public void invoke(ImportRecordMaintenanceDto importRecordMaintenanceDto, AnalysisContext analysisContext) {
        RecordMaintenance recordMaintenance = new RecordMaintenance();
        BeanUtil.copyProperties(importRecordMaintenanceDto, recordMaintenance, true);
        recordMaintenance.setIsDelete(0);
        recordMaintenanceMapper.insert(recordMaintenance);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
